/**
 * Created by jessy on 2015/10/19.
 */
$(document).ready(function(){
    alert("第一种方法。");
    // 登录form
    var login=document.getElementById("login_form");
    // 注册form
    var register=document.getElementById("register_form");
    var register_button=document.getElementById("register_button");
    register_button.onclick=function() {
        login.className = "form-signin hide";
        register.className = "form-sign";

    }
    var register_repassword = document.getElementById("register_repassword");
    var register_submit = document.getElementById("register_submit");

    /*register_repassword.onkeyup=function(){

    }*/
    register_submit.onclick = function () {
       $("#rep_span").html("");
       var username = $("#register_username").val();
       var password = $("#register_password").val();
       var repassword = $("#register_repassword").val();
            if (password != repassword) {
                $("#rep_span").removeClass("hidden");
                $("#rep_span").html("密码不一致");
                return false;
            }else{
                $.ajax({
                    url: util.getUrl() + '/register',
                    data: {"username": username, "password": password},
                    type: "POST",
                    dataType: "json",
                    success: function (data1) {
                        alert(data1);
                    },
                    error:function(data2,e,r){
                      alert(data2.status);
                        alert(e);
                        alert(r);
                    }
                });
            }
        }
    function refreshImage() {
        document.getElementById("captchaImage").setAttribute("src",
            "/Kaptcha.jpg?" + Math.round(Math.random() * 10000));
    }
});